import { BaseItem } from "../../common/BaseItem";
import { TSkill } from "../../../../../Message/Db/Tables/TSkill";
import { Language } from "../../../../../extend/language/Language";
import { EPetSkillSoul } from "../../../../../Message/Game/EPetSkillSoul";
import { GameDefConfig } from "../../../resource/GameDefConfig";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { ToolTipInfo } from "../../../model/ToolTipInfo";
import { Tooltip } from "../../common/tooltip/Tooltip";
import { SPetSkill } from "../../../../../Message/Game/SPetSkill";
import { SkillConfig } from "../../../resource/SkillConfig";
import { FilterConst } from "../../../../component/gconst/FilterConst";
//class TSkillItem
    
    export  class TSkillItem extends BaseItem
    {
        constructor()
        {
            super();
            return;
        }

        public get skill(): TSkill
        {
            return this._skill;
        }

        public set skill(arg1: TSkill)
        {
            this._skill = arg1;
            if (this._skill) 
            {
                this.source = this._skill.skillIcon + ".jpg";
            }
            else 
            {
                this.source = null;
            }
            this.drawNow();
            return;
        }

        public /* override */ get toolTipData()
        {
            var loc2=null;
            var loc1="";
            var loc3="";
            var loc4="";
            var loc5="";
            if (this._skill) 
            {
                posType = this._skill.posType;
                if (posType != 0) 
                {
                    if (posType == 1) 
                    {
                        loc2 = Language.getString(54088);
                    }
                }
                else 
                {
                    loc2 = Language.getString(54087);
                }
                if (this._petSkill && this._petSkill.isGift == 1) 
                {
                    loc4 = Language.getString(54139);
                }
                else 
                {
                    loc4 = "";
                }
                if (this._petSkill && this._petSkill.isSoul == EPetSkillSoul._EPetSkillSoulYes) 
                {
                    loc5 = Language.getString(54450);
                }
                else 
                {
                    loc5 = "";
                }
                loc3 = GameDefConfig.instance.getSkillUseType(this._skill.useType).name;
                loc1 = loc1 + ("<font color=\'#F5FF00\'size=\'14\'><b>" + this._skill.skillName + "</b></font><br>");
                loc1 = loc1 + HTMLUtil.addColor(loc2 + "    " + loc4 + "    " + loc5 + "<br><br>", "#a768c6");
                loc1 = loc1 + HTMLUtil.addColor(this._skill.skillDescription + "<br><br>", "#ffffff");
                loc1 = loc1 + HTMLUtil.addColor(Language.getString(54171) + this._skill.skillLevel + "<br>", "#f5ff00");
                loc1 = loc1 + HTMLUtil.addColor(Language.getString(54090) + loc3 + "<br>", "#f5ff00");
                loc1 = loc1 + HTMLUtil.addColor(Language.getString(54092) + this._skill.attackDistance + "<br>", "#f5ff00");
                loc1 = loc1 + HTMLUtil.addColor(Language.getString(54093) + this._skill.cooldownTime / 1000 + Language.getString(54089) + "<br>", "#f5ff00");
                return new ToolTipInfo(Tooltip.ToolTipRenderType_ShortcutItem, loc1);
            }
            return null;
        }

        public /* override */ set data(arg1: Object)
        {
            super.data = arg1;
            if (arg1) 
            {
                this._petSkill = arg1 as SPetSkill;
                this.skill = SkillConfig.instance.getInfoByName(this._petSkill.skillId);
            }
            else 
            {
                this._petSkill = null;
                this.skill = null;
            }
            this.drawNow();
            return;
        }

        public /* override */ set selected(arg1: Boolean)
        {
            if (arg1) 
            {
                this.filters = [FilterConst.itemChooseFilter];
            }
            else 
            {
                this.filters = [];
            }
            this.dispatchEvent(new Object /* flash.events.Event */(flash.events.Event.CHANGE, true));
            return;
        }

        public get petSkill(): SPetSkill
        {
            return this._petSkill;
        }

        /* internal */ /* var */_petSkill: SPetSkill;

        /* internal */ /* var */_skill: TSkill;
    }
